package com.zhouk.ams.mapper;

import com.zhouk.ams.domain.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface UserMapper {

    public static final String TABLE_NAME = "ams_users";
    int deleteByPrimaryKey(Integer id);

    //int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    @Select("select * from " + TABLE_NAME + " where username=#{username}")
    User findUserByName(@Param("username") String username);

    @Insert("insert into " + TABLE_NAME + "(username,password) values(#{username},#{password})")
    int insert(User user);

    @Update("update " + TABLE_NAME + " set username=#{username},password=#{password} where id=#{id}")
    int updateById(User user);
}